<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition>
	<h:form id="form">
		<a4j:queue requestDelay="500" ignoreDupResponses="true"/>

		<h:panelGrid columns="2" columnClasses="top , top">
			<rich:extendedDataTable value="#{addressBean.itemsDataModel}"
				var="record" id="table" style="width: 580px; height: 290px;"
				sortMode="#{addressBean.sortMode}"
				sortPriority="#{addressBean.sortPriorities}"
				selectionMode="#{addressBean.selectionMode}"
				selection="#{addressBean.selection}" rows="50"
				>

				<a4j:ajax execute="@form" event="selectionchange"
					listener="#{addressBean.selectionListener}"
					render=":addressBean_selectiontable" />

            	<f:facet name="noData">
                	Nothing found
            	</f:facet>

				<ui:include src="/templates/include/jpaColumn.xhtml">
					<ui:param name="bean" value="#{addressBean}" />
					<ui:param name="beanData" value="#{record.country}" />
					<ui:param name="property" value="country" />
					<ui:param name="headerText" value="#{bundle['entities.address.country']}" />
					<ui:param name="textFilterRendered" value="true"/>
					<ui:param name="columnWidth" value="140px;"/>
				</ui:include>

				<ui:include src="/templates/include/jpaColumn.xhtml">
					<ui:param name="bean" value="#{addressBean}" />
					<ui:param name="beanData" value="#{record.city}" />
					<ui:param name="property" value="city" />
					<ui:param name="headerText"
						value="#{bundle['entities.address.city']}" />
					<ui:param name="textFilterRendered" value="true"/>
					<ui:param name="columnWidth" value="150px;"/>
				</ui:include>

				<ui:include src="/templates/include/jpaColumn.xhtml">
					<ui:param name="bean" value="#{addressBean}" />
					<ui:param name="beanData" value="#{record.streetName}" />
					<ui:param name="property" value="streetName" />
					<ui:param name="headerText"
						value="#{bundle['entities.address.streetName']}" />
					<ui:param name="textFilterRendered" value="true"/>
					<ui:param name="columnWidth" value="185px;"/>
				</ui:include>

				<ui:include src="/templates/include/jpaColumn.xhtml">
					<ui:param name="bean" value="#{addressBean}" />
					<ui:param name="beanData" value="#{record.zip}" />
					<ui:param name="property" value="zip" />
					<ui:param name="headerText"
						value="#{bundle['entities.address.zip']}" />
					<ui:param name="textFilterRendered" value="true"/>
					<ui:param name="columnWidth" value="100px;"/>
				</ui:include>

			</rich:extendedDataTable>
			<h:panelGroup layout="block" style="width:500px">
				<rich:panel>
					<f:facet name="header">
						<h:outputText value="#{bundle['windows.sortSelectionModes.title']}" />
					</f:facet>
					<h:panelGrid columns="2">
						<!--
						<h:outputText value="#{bundle['windows.sortSelectionModes.sortMode']}" />
						<rich:select value="#{addressBean.sortMode}" defaultLabel="#{bundle['windows.sortSelectionModes.selectionMode.Multi']}">
							<a4j:ajax execute="@form" event="selectitem" render=":table"/>

							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.sortMode.Single']}" itemValue="single" />
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.sortMode.Multi']}" itemValue="multiple" />
						</rich:select>
						-->
						<h:outputText value="#{bundle['windows.sortSelectionModes.selectionMode']}" />
						<rich:select value="#{addressBean.selectionMode}" defaultLabel="#{bundle['windows.sortSelectionModes.selectionMode.Multi']}">
							<a4j:ajax execute="@form" event="selectitem" render=":table"/>

							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.selectionMode.Single']}" itemValue="single" />
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.selectionMode.Multi']}" itemValue="multiple" />
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.selectionMode.None']}" itemValue="none" />
						</rich:select>
					</h:panelGrid>
				</rich:panel>
			    <rich:panel>
			        <f:facet name="header">
			            <h:outputText value="#{bundle['windows.entities.address.Actions']}"></h:outputText>
			        </f:facet>
			            <a4j:commandButton action="#{addressBean.removeSelected}" value="#{bundle['entities.removeSelectedRecords']}"  reRender="table,addressBean_selectiontable"/>
			    </rich:panel>
			    <rich:panel>
			        <f:facet name="header">
			            <h:outputText value="#{bundle['windows.entities.address.NewEntity']}"></h:outputText>
			        </f:facet>
			        <h:panelGrid columns="2">
			            <h:outputText value="#{bundle['entities.address.country']}"/>
			            <rich:inplaceInput defaultLabel="click to enter country" value="#{addressBean.address.country}" />
			            <h:outputText value="#{bundle['entities.address.city']}"/>
			            <rich:inplaceInput defaultLabel="click to enter city" value="#{addressBean.address.city}" />
			            <h:outputText value="#{bundle['entities.address.streetName']}"/>
			            <rich:inplaceInput defaultLabel="click to enter street name" value="#{addressBean.address.streetName}" />
			            <h:outputText value="#{bundle['entities.address.zip']}"/>
			            <rich:inplaceInput defaultLabel="click to enter zip code" value="#{addressBean.address.zip}" />
			            <a4j:commandButton action="#{addressBean.createNew}" value="#{bundle['entities.createNewRecord']}" reRender="table,addressBean_selectiontable"/>
			        </h:panelGrid>
				</rich:panel>
			</h:panelGroup>
		</h:panelGrid>

		<rich:panel>
			<f:facet name="header">
				<h:outputText value="#{bundle['windows.currentlySelected.title']}" />
			</f:facet>
			<rich:dataTable value="#{addressBean.selectionItems}" var="sel"
				id="addressBean_selectiontable">
				<rich:column width="200px">
					<h:outputText value="#{sel.country}" />
				</rich:column>
				<rich:column width="200px">
					<h:outputText value="#{sel.city}" />
				</rich:column>
				<rich:column width="200px">
					<h:outputText value="#{sel.streetName}" />
				</rich:column>
				<rich:column width="120px">
					<h:outputText value="#{sel.zip}" />
				</rich:column>
			</rich:dataTable>
		</rich:panel>

	</h:form>
</ui:composition>

</html>
